//
//  HomeStrategyDetailCell.m
//  GiftNote
//
//  Created by lanou on 15/8/17.
//  Copyright (c) 2015年 GN. All rights reserved.
//

#import "HomeStrategyDetailCell.h"
#import "HomeHeader.h"
#import "UIImageView+WebCache.h"

@implementation HomeStrategyDetailCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, (kHomeWidth - 30) / 2, (kHomeWidth - 30) / 2)];
        [self.contentView addSubview:_imageView];
        
        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(_imageView.frame) + 10, (kHomeWidth - 30) / 2 - 20, 40)];
        _nameLabel.numberOfLines = 2;
        _nameLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_nameLabel];
        
        _priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(_nameLabel.frame) + 5, _nameLabel.frame.size.width / 2, 20)];
        _priceLabel.font = [UIFont systemFontOfSize:14];
        _priceLabel.textColor = [UIColor redColor];
        _priceLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_priceLabel];
        
        _countLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_priceLabel.frame) + 30, _priceLabel.frame.origin.y, _nameLabel.frame.size.width / 2 - 30, 20)];
        _countLabel.textColor = [UIColor grayColor];
        _countLabel.font = [UIFont systemFontOfSize:10];
        _countLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_countLabel];
        
    }
    return self;
}

- (void)setDetailModel:(HomeStrategyDetailModel *)detailModel
{
    _detailModel = detailModel;
    [_imageView sd_setImageWithURL:[NSURL URLWithString:_detailModel.cover_image_url] placeholderImage:nil];
    
    _nameLabel.text = _detailModel.name;
    _priceLabel.text = [NSString stringWithFormat:@"￥ %@",_detailModel.price];
    _countLabel.text = [NSString stringWithFormat:@"%d",[_detailModel.favorites_count intValue]];
    
}


@end







